<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2017 the OpenProject Foundation (OPF)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

See doc/COPYRIGHT.rdoc for more details.

++#%><!DOCTYPE html>
<% show_decoration = params["layout"].nil? %>
<html xmlns="http://www.w3.org/1999/xhtml" lang="<%= I18n.locale.to_s %>" xml:lang="<%= I18n.locale.to_s %>" class="<%= 'in_modal' unless show_decoration %>">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title><%= html_title %></title>
    <meta name="viewport" content="width=device-width">
    <meta name="description" content="<%= OpenProject::Info.app_name %>" />
    <meta name="keywords" content="issue,bug,type" />
    <meta name="app_base_path" content="<%= OpenProject::Configuration['rails_relative_url_root'] || '' %>" />
    <base href="<%= OpenProject::Configuration['rails_relative_url_root'] || '' %>/" />
    <meta name="current_menu_item" content="<%= current_menu_item %>" />
    <meta name="accessibility-mode" content="<%= current_user.impaired? %>" />
    <%= csrf_meta_tags %>
    <%= render 'common/favicons' %>
    <%= stylesheet_link_tag 'openproject', media: "all" %>
    <%= javascript_include_tag 'application' %>
    <%= javascript_include_tag "locales/#{I18n.locale}" %>
    <!-- user specific tags -->
    <%= user_specific_javascript_includes %>
    <!-- project specific tags -->
    <%= call_hook :view_layouts_base_html_head %>
    <!-- page specific tags -->
    <%= content_for(:header_tags) if content_for?(:header_tags) %>
    <% if EnterpriseToken.allows_to?(:define_custom_style) && CustomStyle.try(:current).present? %>
      <% cache(CustomStyle.current) do %>
        <%= render partial: "custom_styles/inline_css" %>
      <% end %>
    <% end %>
  </head>
  <body class="<%= body_css_classes %>" ng-app="openproject" data-relative_url_root="<%= root_path %>" ng-init="projectIdentifier = '<%= (@project.identifier rescue '') %>'">
    <noscript>
      <div class="top-shelf icon icon-warning">
        <h1><%=l(:noscript_heading)%></h1>
        <p>
          <%=l(:noscript_description)%>
        </p>
        <h2>
          <a href="http://www.enable-javascript.com/" target="_blank"><%=l(:noscript_learn_more) %></a>
        </h2>
      </div>
    </noscript>
    <% main_menu = render_main_menu(@project) %>
    <% side_displayed = content_for?(:sidebar) || content_for?(:main_menu) || !main_menu.blank? %>
    <% initial_classes = initial_menu_classes(side_displayed, show_decoration) %>
    <div id="wrapper" style="<%= initial_menu_styles %>" class="<%= initial_classes %>"
         ng-class="{ 'hidden-navigation': !showNavigation }">
      <% if show_decoration %>
        <div id="top-menu">
          <div id="header">
            <div id="top-menu-items">
              <h1 class="hidden-for-sighted">
                <%= l(:label_top_menu) %>
              </h1>
              <a href="" onclick="skipMenu();"
                  class="hidden-for-sighted skip-navigation-link"
                  aria-label="<%= I18n.t('js.work_packages.jump_marks.label_content') %>">
                    <%= I18n.t('js.work_packages.jump_marks.content') %>
              </a>
              <%= render_top_menu_left %>
              <div id="logo" class="hidden-for-mobile">
                <%= link_to(I18n.t('label_home'), home_url, class: 'home-link') %>
              </div>
              <%= call_hook :view_layouts_base_top_menu %>
              <div class="top-menu-items-right">
                <%= render partial: 'search/mini_form' %>
                <%= render_top_menu_right %>
              </div>
            </div>
          </div>
        </div>
      <% end %>
      <div id="main"
           class="<%= initial_classes %>"
           ng-class="{ 'hidden-navigation': !showNavigation }">
        <% if (side_displayed && show_decoration) %>
          <div id="main-menu" ng-controller="MainMenuController as mainMenu">
            <h1 class="hidden-for-sighted"><%= l(:label_main_menu) %></h1>
            <div id="toggle-project-menu"
          ng-class="{ 'show': !showNavigation }">
              <a href="javascript:;" title="<%= l(:show_hide_project_menu) %>"
            ng-click="mainMenu.toggleNavigation()"
            class="navigation-toggler icon4 icon-double-arrow-left"></a>
            </div>
            <div id="menu-sidebar">
              <%= main_menu %>
              <%= content_for :main_menu %>
              <!-- Sidebar -->
              <div id="sidebar">
                <%= content_for :sidebar %>
                <%= call_hook :view_layouts_base_sidebar %>
              </div>
            </div>
          </div>
        <% end %>
        <% if show_decoration %>
          <div id="breadcrumb" class="<%= initial_classes %><%= show_breadcrumb ? ' -show' : '' %>"
               ng-class="{ 'hidden-navigation': !showNavigation }">
            <%= you_are_here_info %>
            <%= full_breadcrumb %>
            <%= call_hook :view_layouts_base_breadcrumb %>
          </div>
        <% end %>
        <%= render_flash_messages %>
        <notifications></notifications>
        <div id="content" class="<%= initial_classes %>"
             ng-class="{ 'hidden-navigation': !showNavigation }">
          <h1 class="hidden-for-sighted"><%= l(:label_content) %></h1>
          <%= content_for :content_body %>
          <% unless local_assigns[:no_action_menu] %>
            <!-- Action menu -->
            <%= render partial: 'layouts/action_menu' %>
            <%= yield %>
          <% end %>
          <%= call_hook :view_layouts_base_content %>
          <% unless local_assigns[:no_action_menu] %>
            <div style="clear:both;">&nbsp;</div>
          <% end %>
        </div>
        <% unless local_assigns[:no_action_menu] %>
          <div style="clear:both;">&nbsp;</div>
        <% end %>
      </div>
      <div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div>
    </div>
    <%# Properly decides main menu expanded state before its drawn. Fixes flickering side menu
        where menu is first expanded, then being collapsed in angular. %>
    <%= javascript_tag do %>
    (function($) {
      var wrapper = $('#wrapper');
      if (window.sessionStorage.getItem('openproject:navigation-toggle') === 'collapsed') {
        $('.can-hide-navigation').addClass('hidden-navigation');
      }
      wrapper.show();
    }(jQuery));
    <% end %>
    <% if (show_decoration) %>
      <div id="footer">
        <div class="footer-content">
          <%= footer_content %>
        </div>
      </div>
    <% end %>
    <%= call_hook :view_layouts_base_body_bottom %>
  </body>
</html>
